<?
$file_path = "site.txt";
global $json_data;
$json_data=array();
if(file_exists($file_path)){
  $str = file_get_contents($file_path);//将整个文件内容读入到一个字符串中
  $data=$str;
}
  //echo $data;
  $data_arr=explode("\n",$data);
  foreach ($data_arr as $value){
    //url
    $str=$value;
    $url_result1 =strstr($str,'——',1); 
    $url_result2= strstr($url_result1 ,'http'); 
    $url=trim($url_result2);
   //echo $url;
    //filecode
    $filecode_result1 =strstr($str,'】',1); 
    $filecode_result2= strstr($filecode_result1 ,' '); 
    $filecode=trim($filecode_result2);
   // echo $filecode; 
    //time
    $time_result1_arr=explode("间：",$str);
    $time=trim($time_result1_arr[1]);
   // echo $time; 
    $json_temp=array(
      'time'=>$time,
      'name'=>$filecode,
      'description'=>$url
    );
    global $json_data;
    array_push($json_data,$json_temp);
  }
  $json_data_arr=array_reverse($json_data);
  $json_arr=array(
    "code"=>0,
    "data"=>$json_data_arr,
    "count"=>count($json_data_arr),
    "msg"=>"成功"
  );
  

  echo json_encode($json_arr);

?>